﻿using System;
using System.Windows;
using System.ComponentModel;
using System.Reflection;

namespace SBPweb.Accelerators.StreetView.Client.BingMapsProvider.Models
{

    public class ModelBase : DependencyObject, IModel
    {

        #region Events

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        #region Methods

        protected void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        public T GetValue<T>(DependencyProperty property)
        {
            return (T)base.GetValue(property);
        }

        public void SetValue<T>(DependencyProperty property, T value)
        {
            SetValue<T>(property, value, null);
        }

        public void SetValue<T>(DependencyProperty property, T value, string propertyName)
        {
            base.SetValue(property, value);
            if (!string.IsNullOrEmpty(propertyName))
            {
                RaisePropertyChanged(propertyName);
            }
        }

        #endregion

    }

}